package com.raising.sc;

import com.ecwid.consul.v1.ConsulClient;
import com.ecwid.consul.v1.ConsulRawClient;
import com.ecwid.consul.v1.agent.model.Service;

import java.util.Map;

/**
 * Hello world!
 *
 */
public class ConsulDemoApi {
    public static void main(String[] args) {
        ConsulRawClient client = new ConsulRawClient("192.168.0.241", 37170);
        ConsulClient consul = new ConsulClient(client);
        //获取所有服务
        Map<String, Service> map = consul.getAgentServices().getValue();
        for (String key : map.keySet()) {
            System.out.println(key + ":" + map.get(key).toString());
        }
    }
}
